package Managing;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;

import Screens.Screen;


public class InputHandle implements KeyListener{
	
	public static boolean up = false, down = false, right = false, left = false;

	public InputHandle(Screen screen){
		screen.addKeyListener(this);
	}
	
	public void toggle(KeyEvent ke, boolean pressed){
		int keyCode = ke.getKeyCode();
		if(keyCode == KeyEvent.VK_W){GameKeys.setKey(GameKeys.UP, pressed);}
		if(keyCode == KeyEvent.VK_S){GameKeys.setKey(GameKeys.DOWN, pressed);}
		if(keyCode == KeyEvent.VK_D){GameKeys.setKey(GameKeys.RIGHT, pressed);}
		if(keyCode == KeyEvent.VK_A){GameKeys.setKey(GameKeys.LEFT, pressed);}
	}
	@Override
	public void keyPressed(KeyEvent e) {
		toggle(e, true);
	}

	@Override
	public void keyReleased(KeyEvent e) {
		toggle(e, false);
	}

	@Override
	public void keyTyped(KeyEvent e) {
		
	}

}
